package com.fedorvlasov.lazylist;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;
import androidstore.app.data.AppData;
import androidstore.app.data.AppFetcher;

public class AppListActivity extends Activity implements OnItemClickListener {
	//public static ArrayList<AppData> appdata = null;
	public static String categoryName = null;
	private ListView list;
	private TextView appCategory ;
	private LazyAdapter adapter;
	ArrayList<AppData> AppList;
	AppFetcher fetcher;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sub);
		
		fetcher = new AppFetcher();
		AppList = fetcher.getCategoryApp(categoryName);
		appCategory = (TextView)findViewById(R.id.categoryName);
		appCategory.setText(categoryName);
        list=(ListView)findViewById(R.id.list);
        adapter=new LazyAdapter(this, AppList);
        list.setOnItemClickListener(this);
        list.setAdapter(adapter);		
	}
    @Override
    public void onItemClick(AdapterView arg0, View v, int position, long arg3) {
    // TODO Auto-generated method stub
    //	Toast.makeText(this, "u clicked " + list.getItemIdAtPosition(position) ,Toast.LENGTH_LONG).show();
    	Intent intent = new Intent(this,AppActivity.class);
    	AppActivity.appdata = AppList.get(position);
    	startActivity(intent);
    }
    	
	
}
